using System;
using System.Collections.Generic;
using System.Windows.Forms;
using System.Diagnostics;

namespace LogAnalyzer
{
    static class Program
    {
        /// <summary>
        /// The main entry point for the application.
        /// </summary>
        [STAThread]
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            
            //Process proc = GetRunningInstance();
            //if (proc != null)
            //{
            //    MessageBox.Show(string.Format(
            //        "Another instance ({0}, HWND={1}) is already running.", proc.MainWindowTitle, proc.MainWindowHandle)
            //        , "Log Analyzer"
            //        , MessageBoxButtons.OK
            //        , MessageBoxIcon.Exclamation);
            //    return;
            //}

            using (AnalyzerApplication logAnalyzer = new AnalyzerApplication())
            {
                logAnalyzer.Run(args);
            }

        }

        /// <summary>
        /// Search for another instance of same application in running processes
        /// </summary>
        /// <returns>Found process, null otherwise</returns>
        private static Process GetRunningInstance()
        {
            Process current = Process.GetCurrentProcess();
            foreach (Process proc in Process.GetProcesses())
            {
                if (proc.Id == current.Id)
                    continue;

                if (proc.ProcessName == current.ProcessName)
                    return proc;
            }

            return null;
        }

    }
}